#include <bits/stdc++.h>
// 2025/01/28
// tag:
// Author: Zhang Muen
using namespace std;

int prime[33] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137 };
int n, m1, m2, factor[33], factor2[33];

void init()
{
    for (int i = 0; i < 33; i++)
        while (m1 % prime[i] == 0)
            factor[i]++, m1 /= prime[i];
    for (int i = 0; i < 33; i++)
        factor[i] *= m2;
}

void init2(int x)
{
    memset(factor2, 0, sizeof(factor2));
    for (int i = 0; i < 33; i++)
        while (x % prime[i] == 0)
            factor2[i]++, x /= prime[i];
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m1 >> m2;
    init();
    int min_ans = INT_MAX;
    for (int i = 0; i < n; i++) {
        int s;
        cin >> s;
        init2(s);
        int ans = 0;
        for (int i = 0; i < 33; i++) {
            int p = factor2[i], cnt = 1;
            if (factor2[i] == 0 && factor[i] != 0) {
                ans = INT_MAX;
                break;
            }
            if (factor2[i] == 0 && factor[i] == 0)
                continue;
            ans = max(ans, factor[i] / factor2[i] + (factor[i] % factor2[i] != 0));
        }
        min_ans = min(min_ans, ans);
    }
    cout << (min_ans == INT_MAX ? -1 : min_ans) << endl;
    return 0;
}